package com.woniuxy.config;

import com.woniuxy.util.ConstantUtil;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {
    @Bean
    public Queue queue(){
        return new Queue(ConstantUtil.REGISTER_QUEUE);
    }

    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(ConstantUtil.REGISTER_EXCHANGE);
    }

    @Bean
    public Binding queueToExchange(){
        return BindingBuilder.bind(queue()).to(topicExchange()).with(ConstantUtil.REGISTER_ROUTING_KEY);
    }

    @Bean
    public Queue aiQueue(){
        return new Queue(ConstantUtil.AI_QUEUE);
    }

    @Bean
    public TopicExchange topicAiExchange(){
        return new TopicExchange(ConstantUtil.AI_EXCHANGE);
    }

    @Bean
    public Binding bindingAiQueueToExchange(){
        return BindingBuilder.bind(aiQueue()).to(topicAiExchange()).with(ConstantUtil.AI_ROUTING_KEY);
    }
}
